﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="framecontainer">
        <div class="listcontainer">
            <div class="searchop">
                <div class="btnop">
                    <button class="btn btn-op" type="button" onclick="OpenAdd()"><span class="btntext">新增列</span></button>
                    <button class="btn btn-op" type="button" onclick="BatchDelete()"><span class="btntext">批量删除</span></button>
                </div>
                <div class="btnop">
                    <span class="searchtext">字段中文名:</span><input id="ColumnName" type="text" class="form-control searchinput" placeholder="请输入代码文字">
                    <span class="searchtext">字段名称:</span><input id="PhysicalColumnName" type="text" class="form-control searchinput" placeholder="请输入代码值">
                    <button class="btn" type="button" onclick="BindGrid()"><i class="icon icon-search"></i><span class="searchtext">查询</span></button>
                </div>
            </div>
            <div class="tableop">
                <table class="GridStyle" id="CloudGrid" keyid="ColumnGuid" url="oplist" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                    <tr class="HeaderStyle">
                        <th scope="col" style="width: 10px;" field="check" rowalign="center"></th>
                        <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                        <th scope="col" field="ColumnName" rowalign="left">字段中文名</th>
                        <th scope="col" field="PhysicalColumnName" rowalign="left">字段名称</th>
                        <th scope="col" field="function" functionname="GetColumnType" rowalign="center" style="width: 160px;">字段类别</th>
                        <th scope="col" field="function" functionname="GetBindControl" rowalign="center" style="width: 100px;">控件类型</th>
                        <th scope="col" style="width: 50px;" field="SortNum" rowalign="center">排序</th>
                        <th scope="col" style="width: 50px;" field="EditButton" functionname="GridEdit" rowalign="center">详细</th>
                    </tr>
                </table>
            </div>
            <div class="bottomop">
                <div class="pageop">
                    <ul class="pagination" id="cloudpagination"></ul>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            BindGrid();
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }

        function SearchParm() {
            return {
                "ColumnName": $("#ColumnName").val(),
                "PhysicalColumnName": $("#PhysicalColumnName").val(),
                "TableGuid": GetUrlParam("tableguid")
            };
        }
        function AfterBindData() {

        }
        function OpenAdd() {
            OpenTopDialog("新增数据列", "frame/dmp/column/add?tableguid=" + GetUrlParam("tableguid"), 400, 800, BindGrid)
        }
        function GridEdit(RowData) {
            OpenTopDialog("编辑数据列", "frame/dmp/column/edit?columnguid=" + RowData.ColumnGuid, 400, 800, BindGrid)

        }
        function BatchDelete() {
            var SelectRows = CloudGridChecked($("#CloudGrid"));
            if (SelectRows.length > 0) {
                OpenConfirm("确认删除选中的数据？", function () {
                    CloudPost({ "KeyID": SelectRows }, "opbatchdelete", function (res) {
                        if (res.code == 0) {
                            OpenSuccess("删除成功！", function () {
                                BindGrid();
                            })
                        } else {
                            OpenFail(res.data);
                        }
                    })
                })
            }
        }
        function GetColumnType(RowData) {
            var text = "";
            switch (RowData.ColumnType) {
                case 10:
                    text = "字符串（nvarchar）"
                    break;
                case 20:
                    text = "整数（int）"
                    break;
                case 30:
                    text = "小数（numeric）"
                    break;
                case 40:
                    text = "日期（datetime）"
                    break;
                case 50:
                    text = "大文本（longtext）"
                    break;
            }
            return "<span>" + text + "</span>";
        }
        function GetBindControl(RowData) {
            var text = "";
            switch (RowData.BindControl) {
                case 10:
                    text = "文本输入框"
                    break;
                case 20:
                    text = "数字框"
                    break;
                case 30:
                    text = "日期选择"
                    break;
                case 40:
                    text = "下拉选择"
                    break;
                case 50:
                    text = "单选组"
                    break;
                case 60:
                    text = "多选组"
                    break;
                case 70:
                    text = "富文本编辑器"
                    break;
            }
            return "<span>" + text + "</span>";
        }
    </script>
</body>
</html>
